package com.situ.day3;

import java.util.Scanner;

import org.junit.Test;

public class HomeWork {

//	1、int[] score={0,0,1,2,3,5,4,5,2,8,7,6,9,5,4,8,3,1,0,2,4,8,7,9,5,2,1,2,3,9};
//	要求求出其中的奇数个数和偶数个数。
	@Test
	public void test1() {
		int[] score={0,0,1,2,3,5,4,5,2,8,7,6,9,5,4,8,3,1,0,2,4,8,7,9,5,2,1,2,3,9};
		int jishuCount = 0;
		int oushuCount = 0;
		for (int i = 0; i < score.length; i++) {
			System.out.println(score[i]);
			if (score[i] % 2 == 0) {
				oushuCount++;
			} else {
				jishuCount++;
			}
		}
		System.out.println("奇数个数：" + jishuCount);
		System.out.println("偶数个数：" + oushuCount);
	}
	
	//2、输入一组学生的成绩，使用数组，然后计算他们的平均值.
	@Test
	public void test2() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入学生数量");
		int count = scanner.nextInt();
		int[] scores = new int[count];
		// code review
	}
	
	
	@Test
	public void test4() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请问需要输入几个学生的成绩");
		int num = scanner.nextInt();
		int[] scores = new int[num];
		int sum = 0;
        for (int i = 0; i < scores.length; i++) {
        	System.out.println("请输入第" + (i + 1) + "个学生的成绩");
        	int number = scanner.nextInt();
        	scores[i] = number;
        	sum = sum + scores[i];
		}
		double average = sum / scores.length;
		System.out.println("这" + num + "个学生的平均数是" + average);
	}
	
	
	//3、输入三个整数x,y,z，请把这三个数由小到大输出。
	@Test
	public void test3() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入第一个数字：");
		int x = scanner.nextInt();
		System.out.println("请输入第二个数字：");
		int y = scanner.nextInt();
		System.out.println("请输入第三个数字：");
		int z = scanner.nextInt();
		
		if (x > y) {
			int temp = x;
			x = y;
			y = temp;
		}
		
		if (x > z) {
			int temp = x;
			x = z;
			z = temp;
		}
		//到这里后，x分别和y和z比较，x现在就是最小的
		//接下来只要比较y和z就可以了
		
		if (y > z) {
			int temp = y;
			y = z;
			z = temp;
		}
		
		System.out.println("x: " + x);
		System.out.println("y: " + y);
		System.out.println("z: " + z);
	}
	
	@Test
	public void test6() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入一个数值X：");
		int X = scanner.nextInt();
		System.out.println("请输入一个数值Y：");
		int Y = scanner.nextInt();
		System.out.println("请输入一个数值Z：");
		int Z = scanner.nextInt();
		if (X < Y && X < Z && Y < Z) {
			System.out.print(X + "\t" + Y + "\t" + Z);
		} else if (Y < Z && Y < X && Z < X) {
			System.out.print(Y + "\t" + Z + "\t" + X);
		} else {
			System.out.print(Z + "\t" + X + "\t" + Y);
		}

	}
}
